package com.controller.wmy;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaMode;
import com.entity.Order;
import com.service.wmy.OrderService;
import com.util.gzp.AjaxResponse;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("order")
@SaCheckRole(value = {"管理员","业务员"},mode = SaMode.OR)
public class OrderController {
    @Autowired(required = true)
    private OrderService orderService;

    @GetMapping
    public AjaxResponse getServiceList(){
        List<Order> orders= orderService.getServiceList();
        return AjaxResponse.success(orders);
    }

    @PostMapping("/add")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "aid",value = "传入业务类型id",required = true,dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "proposername",value = "申请人姓名",required = true,dataTypeClass = String.class),
            @ApiImplicitParam(name = "proposeridcard",value = "申请人身份证号",required = true,dataTypeClass = String.class),
            @ApiImplicitParam(name = "agentname",value = "代理人姓名",required = true,dataTypeClass = String.class),
            @ApiImplicitParam(name = "agentidcard",value = "代理人身份证号",required = true,dataTypeClass = String.class)
    })
    public AjaxResponse add(Integer aid,String proposername,String proposeridcard,String agentname,String agentidcard){

        orderService.addServiceAndclient(aid,proposername,proposeridcard,agentname,agentidcard);
        return AjaxResponse.success("成功");
    }
}
